Change in openvpn[master]: buffer: Fix buf_parse eating input
A message that is not in the archive (sent off-list or not yet received): gerrit.1759330832000.I3724660bf0f8336ee58c172acfb7c4f38e457393@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1246?usp=email
to review the following change.
Change subject: buffer: Fix buf_parse eating input
......................................................................
buffer: Fix buf_parse eating input
When parsing a "line" that is longer than the
available line buffer, then buf_parse was
eating up to 2 characters. It advanced past
them but they were not part of the output.
This can lead to unexpected results if buf_parse
is used in a while loop on unrestricted input,
like e.g. when reading configs (see in_src_get()
used for check_inline_file_via_buf()).
---
M src/openvpn/buffer.c
M src/openvpn/buffer.h
M tests/unit_tests/openvpn/test_buffer.c
3 files changed, 73 insertions(+), 7 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/46/1246/1
src/openvpn/buffer.c +9 -4
@@ -832,19 +832,24 @@do { - c =buf_read_u8 (buf); + c =buf_peek_u8 (buf);if (c <0 ) { eol = true; + line[n] =0 ; +break ; } -if (c <=0 || c == delim) +if (c == delim) { - c =0 ; +buf_advance (buf,1 ); + line[n] =0 ; +break ; } -if (n >= size) +if (n >= (size -1 )) {break ; } +buf_advance (buf,1 ); line[n++] = (char )c; }while (c);
src/openvpn/buffer.h +12 -2
@@ -771,7 +771,7 @@ }static inline int -buf_read_u8 (struct buffer *buf) +buf_peek_u8 (struct buffer *buf) {int ret;if (BLEN (buf) <1 )
@@ -779,7 +779,17 @@return -1 ; } ret = *BPTR (buf); -buf_advance (buf,1 ); +return ret; +} + +static inline int +buf_read_u8 (struct buffer *buf) +{ +int ret =buf_peek_u8 (buf); +if (ret >=0 ) + { +buf_advance (buf,1 ); + }return ret; }
tests/unit_tests/openvpn/test_buffer.c +52 -1
65 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1246?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3724660bf0f8336ee58c172acfb7c4f38e457393
Gerrit-Change-Number: 1246
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1246?usp=email )
Change subject: buffer: Fix buf_parse eating input
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1246?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3724660bf0f8336ee58c172acfb7c4f38e457393
Gerrit-Change-Number: 1246
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 08 Oct 2025 10:29:48 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH 1/1 buffer: Fix buf_parse eating input
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]...>
When parsing a "line" that is longer than the
available line buffer, then buf_parse was
eating up to 2 characters. It advanced past
them but they were not part of the output.
This can lead to unexpected results if buf_parse
is used in a while loop on unrestricted input,
like e.g. when reading configs (see in_src_get()
used for check_inline_file_via_buf()).
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1246
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1246
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/buffer.c +9 -4
@@ -832,19 +832,24 @@do { - c =buf_read_u8 (buf); + c =buf_peek_u8 (buf);if (c <0 ) { eol = true; + line[n] =0 ; +break ; } -if (c <=0 || c == delim) +if (c == delim) { - c =0 ; +buf_advance (buf,1 ); + line[n] =0 ; +break ; } -if (n >= size) +if (n >= (size -1 )) {break ; } +buf_advance (buf,1 ); line[n++] = (char )c; }while (c);
src/openvpn/buffer.h +12 -2
@@ -771,7 +771,7 @@ }static inline int -buf_read_u8 (struct buffer *buf) +buf_peek_u8 (struct buffer *buf) {int ret;if (BLEN (buf) <1 )
@@ -779,7 +779,17 @@return -1 ; } ret = *BPTR (buf); -buf_advance (buf,1 ); +return ret; +} + +static inline int +buf_read_u8 (struct buffer *buf) +{ +int ret =buf_peek_u8 (buf); +if (ret >=0 ) + { +buf_advance (buf,1 ); + }return ret; }
tests/unit_tests/openvpn/test_buffer.c +52 -1
65 lines not on this page · raw message
[Openvpn-devel] [PATCH applied] Re: buffer: Fix buf_parse eating input
So - stared at code, typical "we have a character here that we can not handle right now, oops, where is did it disappear to?" thing, and the peek() fix makes sense. Also, tested against #1247, which fails without this patch, and succeeds afterwards. BB is happy as well, and we get a new UT test...
Recorded the second +2 in gerrit here in the commit, the mail does not show it due to "fingers too fast" timing :) - but gerrit has it.
Your patch has been applied to the master branch.
commit f5a2e2319bc7c3cce7f5cdccae44b9bae3e33375
Author: Frank Lichtenheld Date: Wed Oct 8 12:29:55 2025 +0200
buffer: Fix buf_parse eating input
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1246
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59243829/
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Attention is currently required from: flichtenheld.
plaisthos has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1246?usp=email )
Change subject: buffer: Fix buf_parse eating input
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1246?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3724660bf0f8336ee58c172acfb7c4f38e457393
Gerrit-Change-Number: 1246
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 08 Oct 2025 10:33:32 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1246?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2, Code-Review+2 by plaisthos
Change subject: buffer: Fix buf_parse eating input
......................................................................
buffer: Fix buf_parse eating input
When parsing a "line" that is longer than the
available line buffer, then buf_parse was
eating up to 2 characters. It advanced past
them but they were not part of the output.
This can lead to unexpected results if buf_parse
is used in a while loop on unrestricted input,
like e.g. when reading configs (see in_src_get()
used for check_inline_file_via_buf()).
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1246
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59243829/
---
M src/openvpn/buffer.c
M src/openvpn/buffer.h
M tests/unit_tests/openvpn/test_buffer.c
3 files changed, 73 insertions(+), 7 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/46/1246/2
src/openvpn/buffer.c +9 -4
@@ -832,19 +832,24 @@do { - c =buf_read_u8 (buf); + c =buf_peek_u8 (buf);if (c <0 ) { eol = true; + line[n] =0 ; +break ; } -if (c <=0 || c == delim) +if (c == delim) { - c =0 ; +buf_advance (buf,1 ); + line[n] =0 ; +break ; } -if (n >= size) +if (n >= (size -1 )) {break ; } +buf_advance (buf,1 ); line[n++] = (char )c; }while (c);
src/openvpn/buffer.h +12 -2
@@ -771,7 +771,7 @@ }static inline int -buf_read_u8 (struct buffer *buf) +buf_peek_u8 (struct buffer *buf) {int ret;if (BLEN (buf) <1 )
@@ -779,7 +779,17 @@return -1 ; } ret = *BPTR (buf); -buf_advance (buf,1 ); +return ret; +} + +static inline int +buf_read_u8 (struct buffer *buf) +{ +int ret =buf_peek_u8 (buf); +if (ret >=0 ) + { +buf_advance (buf,1 ); + }return ret; }
tests/unit_tests/openvpn/test_buffer.c +52 -1
65 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1246?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3724660bf0f8336ee58c172acfb7c4f38e457393
Gerrit-Change-Number: 1246
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1246?usp=email )
Change subject: buffer: Fix buf_parse eating input
......................................................................
buffer: Fix buf_parse eating input
When parsing a "line" that is longer than the
available line buffer, then buf_parse was
eating up to 2 characters. It advanced past
them but they were not part of the output.
This can lead to unexpected results if buf_parse
is used in a while loop on unrestricted input,
like e.g. when reading configs (see in_src_get()
used for check_inline_file_via_buf()).
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1246
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59243829/
---
M src/openvpn/buffer.c
M src/openvpn/buffer.h
M tests/unit_tests/openvpn/test_buffer.c
3 files changed, 73 insertions(+), 7 deletions(-)
src/openvpn/buffer.c +9 -4
@@ -832,19 +832,24 @@do { - c =buf_read_u8 (buf); + c =buf_peek_u8 (buf);if (c <0 ) { eol = true; + line[n] =0 ; +break ; } -if (c <=0 || c == delim) +if (c == delim) { - c =0 ; +buf_advance (buf,1 ); + line[n] =0 ; +break ; } -if (n >= size) +if (n >= (size -1 )) {break ; } +buf_advance (buf,1 ); line[n++] = (char )c; }while (c);
src/openvpn/buffer.h +12 -2
@@ -771,7 +771,7 @@ }static inline int -buf_read_u8 (struct buffer *buf) +buf_peek_u8 (struct buffer *buf) {int ret;if (BLEN (buf) <1 )
@@ -779,7 +779,17 @@return -1 ; } ret = *BPTR (buf); -buf_advance (buf,1 ); +return ret; +} + +static inline int +buf_read_u8 (struct buffer *buf) +{ +int ret =buf_peek_u8 (buf); +if (ret >=0 ) + { +buf_advance (buf,1 ); + }return ret; }
tests/unit_tests/openvpn/test_buffer.c +52 -1
65 lines not on this page · raw message
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1246?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I3724660bf0f8336ee58c172acfb7c4f38e457393
Gerrit-Change-Number: 1246
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>